//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Resource Application Block
//===============================================================================

using System.Configuration;
using System.Xml;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.Configuration;
using EntLibContrib.Resource.Providers;
using EntLibContrib.Resource.Configuration;

namespace EntLibContrib.Resource.Tests
{
	static class TestConfigurationSource
	{
		public static DictionaryConfigurationSource GenerateConfiguration ()
		{
			DictionaryConfigurationSource sections = new DictionaryConfigurationSource();
			sections.Add(ResourceManagerSettings.SectionName, GenerateResourceManagerSettings());
			return sections;
		}

		public static DictionaryConfigurationSource GenerateConfigurationWithInstrumentation ()
		{
			DictionaryConfigurationSource sections = GenerateConfiguration();
			sections.Add(InstrumentationConfigurationSection.SectionName, GenerateInstrumentationSettings());
			return sections;
		}

		private static ResourceManagerSettings GenerateResourceManagerSettings ()
		{
			ResourceManagerSettings settings = new ResourceManagerSettings();
			settings.DefaultResourceManager = "AssemblyResourceManager";

			settings.ResourceProviders.Add(new AssemblyResourceProviderData("AssemblyResourceProvider", "EntLibContrib.Resource.TestStore", "EntLibContrib.Resource.TestStore.Properties.Resources"));
			settings.ResourceProviders.Add(new AssemblyResourceProviderData("AssemblyWithBadResourceProvider", "EntLibContrib.Resource.TestStore", "badname"));

			settings.ResourceManagers.Add(new ResourceManagerData("AssemblyResourceManager", "AssemblyResourceProvider"));
			settings.ResourceManagers.Add(new ResourceManagerData("ResourceManagerWithBadResourceProviderInstance", ""));
			settings.ResourceManagers.Add(new ResourceManagerData("ResourceManagerWithBadResourceProviderType", "BadResourceProviderType"));
			settings.ResourceManagers.Add(new ResourceManagerData("ResourceManagerWithBadResourceProvider", "AssemblyWithBadResourceProvider"));

			return settings;
		}

		private static InstrumentationConfigurationSection GenerateInstrumentationSettings ()
		{
			InstrumentationConfigurationSection settings = new InstrumentationConfigurationSection(true, true, true);

			return settings;
		}
	}
}